#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from tortoise import fields

from app.base.base_model import (
    BaseModel, BaseCreatedUpdatedModel
)

class User(BaseModel, BaseCreatedUpdatedModel):
    username = fields.CharField(max_length=30, null=False, unique=True, description="用户名称")
    password = fields.CharField(max_length=100, null=True, description="密码")
    sex = fields.IntField(default=0, description="性别（0男 1女 2未知）")
    user_type = fields.IntField(default=1, description="用户类型（0系统用户）")
    alias = fields.CharField(max_length=30, null=True, default='', description="别名")
    email = fields.CharField(max_length=50, null=True, default='', description="邮箱")
    phone = fields.CharField(max_length=11, null=True, default='', description="电话")
    status = fields.IntField(default=0, description="账户状态（0正常 1禁用）")
    login_ip = fields.CharField(default='',max_length=100, null=True, description="登录ip")
    login_date = fields.DatetimeField(null=True, description="最后登录时间")
    avatar = fields.CharField(default='',max_length=100, description="头像地址")
    remark = fields.CharField(default='',max_length=500, description="备注")
    roles = fields.ManyToManyField("models.Role", related_name="user_role")
    
    class Meta:
        table = 'user'